package com.yanqu.road.entity.player;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.config.passroad.UserPassRoadEvent;

import java.util.List;

/**
 * 玩家新关卡骑驴数据
 */
public class UserPassRoad extends DataObject {

	private long userId;

	private int passId;

	private int passProgress;

	private int buyBuffTimes;

	private int itemBuyBuffTimes;

	private long modifyTime;

	private String eventData = "{}";

	private int transportId;

	//用来版本更新的时候吧之前没有加上去的事件重新放到背包
	private boolean isEventUpdate;

	private List<UserPassRoadEvent>  userPassRoadEvents;

	private long maxRequestTimesOneSecond;

	//章节：埋点使用（1开始）
	private int sessionId;

	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		if (this.userId != userId) {
			this.userId = userId;
			setUpdateOption();
		}
	}

	public int getPassId() {
		return passId;
	}

	public void setPassId(int passId) {
		if(this.passId != passId){
			this.passId = passId;
			setUpdateOption();
		}
	}

	public int getPassProgress() {
		return passProgress;
	}

	public void setPassProgress(int passProgress) {
		if(this.passProgress != passProgress) {
			this.passProgress = passProgress;
			setUpdateOption();
		}
	}

	public int getBuyBuffTimes() {
		return buyBuffTimes;
	}

	public void setBuyBuffTimes(int buyBuffTimes) {
		if(this.buyBuffTimes != buyBuffTimes) {
			this.buyBuffTimes = buyBuffTimes;
			setUpdateOption();
		}
	}

	public int getItemBuyBuffTimes() {
		return itemBuyBuffTimes;
	}

	public void setItemBuyBuffTimes(int itemBuyBuffTimes) {
		if(this.itemBuyBuffTimes != itemBuyBuffTimes) {
			this.itemBuyBuffTimes = itemBuyBuffTimes;
			setUpdateOption();
		}
	}

	public long getModifyTime() {
		return modifyTime;
	}

	public void setModifyTime(long modifyTime) {
		if(this.modifyTime != modifyTime) {
			this.modifyTime = modifyTime;
			setUpdateOption();
		}
	}

	public String getEventData() {
		return eventData;
	}

	public void setEventData(String eventData) {
		if(!eventData.equals(this.eventData)){
			this.eventData = eventData;
			setUpdateOption();
		}
	}

	public int getTransportId() {
		return transportId;
	}

	public void setTransportId(int transportId) {
		if(this.transportId != transportId){
			this.transportId = transportId;
			setUpdateOption();
		}
	}

	public boolean isEventUpdate() {
		return isEventUpdate;
	}

	public void setEventUpdate(boolean eventUpdate) {
		if(eventUpdate != this.isEventUpdate){
			isEventUpdate = eventUpdate;
			setUpdateOption();
		}
	}

	public List<UserPassRoadEvent> getUserPassRoadEvents() {
		return userPassRoadEvents;
	}

	public void setUserPassRoadEvents(List<UserPassRoadEvent> userPassRoadEvents) {
		this.userPassRoadEvents = userPassRoadEvents;
	}

	public void addUserPassRoadEvent(UserPassRoadEvent event){
		for(UserPassRoadEvent eventHas : userPassRoadEvents){
			if(eventHas.getPassId() == event.getPassId()){
				if(eventHas.getSectionId() == event.getSectionId()){
					if(eventHas.getEventId() == event.getEventId()){
						return;
					}
				}
			}
		}
		this.userPassRoadEvents.add(event);
	}

	public void removeUserPassRoadEvent(int passId, int sectionId,int eventId) {
		UserPassRoadEvent rmEvent = null;
		for(UserPassRoadEvent event : userPassRoadEvents){
			if(passId == event.getPassId()){
				if(sectionId == event.getSectionId()){
					if(eventId == event.getEventId()){
						rmEvent = event;
					}
				}
			}
		}
		if(rmEvent != null){
			userPassRoadEvents.remove(rmEvent);
		}
	}

	public long getMaxRequestTimesOneSecond() {
		return maxRequestTimesOneSecond;
	}

	public void setMaxRequestTimesOneSecond(long maxRequestTimesOneSecond) {
		if (this.maxRequestTimesOneSecond < maxRequestTimesOneSecond) {
			this.maxRequestTimesOneSecond = maxRequestTimesOneSecond;
			setUpdateOption();
		}
	}

	public int getSessionId() {
		return sessionId;
	}

	public void setSessionId(int sessionId) {
		if(this.sessionId != sessionId) {
			this.sessionId = sessionId;
			setUpdateOption();
		}
	}
}
